﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class TitlePanel : GUIPanel
{


		float buttonUnlockTime;
		float spriteAlphaTime = 2.4f;

		[SerializeField]
		private GameObject
				PlayButton;
	
		bool PlayButtonOnceFlag;

		public static bool isGameOverOrNotStart = false;

		//ADD ******************** hasegawa **********************
		void Start ()
		{
				PlayButtonOnceFlag = true;
		}

		//**********************************************************


		public override void OnOpen ()
		{
				base.OnOpen ();

				init ();
		}

		void init ()
		{
				buttonUnlockTime = Time.time + spriteAlphaTime;

				// Restart Title TweenAlpha
				UtilManager.Instance.StartNGUIAlphaAnim (gameObject, spriteAlphaTime);
		}


		public void OnClickStartButton ()
		{
				isGameOverOrNotStart = true;
				if (buttonUnlockTime > Time.time) {
						return;
				}

				if (PlayButtonOnceFlag) {

					
						PlayButton.GetComponent<TweenPosition> ().enabled = true;

//						TransitionMgr.Instance.StartTransitionTitleToInGame (gameObject);
						//Debug.LogError("");
						PlayButtonOnceFlag = false;

						StartCoroutine (_delayToStartInGame ());

				}

		}

		IEnumerator _delayToStartInGame ()
		{
				yield return new WaitForSeconds (2);

				// start in game

				CloseSelf ();
				GameMain.Instance.InitInGame ();
		}


	
}
